<?php

class Core_Controller_Router_Route_ChainFix extends Zend_Controller_Router_Route_Chain {
	public function assemble($data = array(), $reset = false, $encode = false) {
		$value = '';
		$numRoutes = count ( $this->_routes );
		$part = null;
		
		foreach ( $this->_routes as $key => $route ) {
			if (! is_null ( $part )) {
				$value .= $this->_separators [$key];
			}
			
			$value .= $part = $route->assemble ( $data, $reset, $encode, (($numRoutes - 1) > $key) );
			
			if (method_exists ( $route, 'getVariables' )) {
				$variables = $route->getVariables ();
				
				foreach ( $variables as $variable ) {
					$data [$variable] = null;
				}
			}
		}
		
		return $value;
	}
}